package com.arpa.wms.domain.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.hibernate.validator.constraints.Length;

import javax.validation.Valid;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 期初 实体
 * @author jinss
 * @date 2020-09-24 13:29:01
 **/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="Initialization对象", description="期初管理")
@TableName("wms_initialization")
/**
 *
 * @author jinss
 * @date 2020-09-25 18:40:25
 **/
public class Initialization extends BasicEntity {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "期初单号")
    @TableField("code")
    @NotBlank(message = "期初单号不能为空", groups = {Update.class})
    private String code;

    @ApiModelProperty(value = "仓库")
    @TableField("warehouse_code")
    @NotBlank(message = "仓库不能为空", groups = {Save.class, Update.class})
    private String warehouseCode;

    @ApiModelProperty(value = "仓库名称")
    @TableField("warehouse_name")
    private String warehouseName;

    @ApiModelProperty(value = "所属机构Code")
    @TableField("group_code")
    private String groupCode;

    @ApiModelProperty(value = "单位总数量")
    @TableField("total_unit_quantity")
    private BigDecimal totalUnitQuantity;

    @ApiModelProperty(value = "基本单位总数量")
    @TableField("total_quantity")
    private BigDecimal totalQuantity;

    @ApiModelProperty(value = "状态")
    @TableField("status")
    @NotBlank(message = "状态不能为空", groups = {Save.class, Update.class})
    private String status;

    @ApiModelProperty(value = "备注")
    @TableField("remarks")
    @Length(max = 255, message = "备注长度不能大于255个字符", groups = {Save.class, Update.class})
    private String remarks;

    @ApiModelProperty(value = "审批人")
    @TableField("approved_by")
    private String approvedBy;

    @ApiModelProperty(value = "审批人名称")
    @TableField("approved_name")
    private String approvedName;

    @ApiModelProperty(value = "审批时间")
    @TableField("gmt_approved")
    private LocalDateTime gmtApproved;

    @ApiModelProperty(value = "审批意见")
    @TableField("approval_opinions")
    private String approvalOpinions;

    @ApiModelProperty(value = "期初单明细")
    @TableField(exist = false)
    @NotEmpty(message = "领用单明细不能为空")
    @Valid
    private List<InitializationItem> initializationItemList = new ValidList<>();

    @ApiModelProperty(value = "期初单要删除的明细code")
    @TableField(exist = false)
    private List<String> deleteCodes;

    public interface Save {

    }

    public interface Update {

    }

}
